﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WuDada.Core.Post;
using WuDada.Core.Post.Service;
using WuDada.Core.Post.Domain;
using System.Text;
using WuDada.Core.Generic.Util;

public partial class index : System.Web.UI.Page
{
    private PostFactory m_PostFactory;
    private IPostService m_PostService;

    protected void Page_Load(object sender, EventArgs e)
    {
        m_PostFactory = new PostFactory();
        m_PostService = m_PostFactory.GetPostService();

        if (!IsPostBack)
        {
            FillAdv();
            FillAdv2();
            FillAdv3();
            FillPartner();
            FillCase();
        }
    }

    private void FillCase()
    {
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", "8");
        conditions.Add("Flag", "1");
        conditions.Add("PageIndex", "0");
        conditions.Add("PageSize", "12");
        conditions.Add("WithOutSubPost", "1");
        IList<PostVO> cases = m_PostService.GetPostList(conditions);

        if (cases != null && cases.Count > 0)
        {
            pnlCases.Visible = true;
            RepeaterCase.DataSource = cases;
            RepeaterCase.DataBind();
        }
        else
        {
            pnlCases.Visible = false;
        }
    }

    private void FillAdv()
    {
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", "12");
        conditions.Add("Flag", "1");
        conditions.Add("PageIndex", "0");
        conditions.Add("PageSize", "6");

        RepeaterAdv.DataSource = m_PostService.GetPostList(conditions);
        RepeaterAdv.DataBind();
    }

    private void FillAdv2()
    {
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", "13");
        conditions.Add("Flag", "1");
        conditions.Add("PageIndex", "0");
        conditions.Add("PageSize", "2");

        RepeaterAdv2.DataSource = m_PostService.GetPostList(conditions);
        RepeaterAdv2.DataBind();
    }

    private void FillAdv3()
    {
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", "14");
        conditions.Add("Flag", "1");
        conditions.Add("PageIndex", "0");
        conditions.Add("PageSize", "1");

        RepeaterAdv3.DataSource = m_PostService.GetPostList(conditions);
        RepeaterAdv3.DataBind();
    }

    private void FillPartner()
    {
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", "10");
        conditions.Add("Flag", "1");

        RepeaterPartner.DataSource = m_PostService.GetPostList(conditions);
        RepeaterPartner.DataBind();
    }
}